package com.huangjue.backend.service.impl;

import com.huangjue.backend.entity.HomeworkReference;
import com.huangjue.backend.mapper.HomeworkReferenceMapper;
import com.huangjue.backend.service.HomeworkReferenceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * 作业附件服务实现类
 */
@Service
public class HomeworkReferenceServiceImpl implements HomeworkReferenceService {
    @Autowired
    private HomeworkReferenceMapper homeworkReferenceMapper;

    /** 根据ID查询附件 */
    @Override
    public HomeworkReference getReferenceById(Integer homeworkReferenceId) {
        return homeworkReferenceMapper.selectById(homeworkReferenceId);
    }

    /** 查询某作业的所有附件 */
    @Override
    public List<HomeworkReference> getReferencesByHomeworkId(Integer homeworkId) {
        return homeworkReferenceMapper.selectByHomeworkId(homeworkId);
    }

    /** 新增附件 */
    @Override
    public boolean addReference(HomeworkReference homeworkReference) {
        return homeworkReferenceMapper.insert(homeworkReference) > 0;
    }

    /** 删除附件 */
    @Override
    public boolean deleteReferenceById(Integer homeworkReferenceId) {
        return homeworkReferenceMapper.deleteById(homeworkReferenceId) > 0;
    }
} 